package org.myname.example1;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;

/**
 * Application Lifecycle Listener implementation class TestHttpSessionAttributeListener
 *
 */
@WebListener
public class TestHttpSessionAttributeListener implements HttpSessionAttributeListener {

    /**
     * Default constructor. 
     */
    public TestHttpSessionAttributeListener() {
        // TODO Auto-generated constructor stub
    }

	/**
     * @see HttpSessionAttributeListener#attributeAdded(HttpSessionBindingEvent)
     */
    public void attributeAdded(HttpSessionBindingEvent event)  { 
    	    String name =event.getName();
    	    String value =event.getValue().toString();
    	    System.out.println("add:name="+name+",value="+value+"\r\n");
    }

	/**
     * @see HttpSessionAttributeListener#attributeRemoved(HttpSessionBindingEvent)
     */
    public void attributeRemoved(HttpSessionBindingEvent event)  { 
        String name =event.getName();
	    String value =event.getValue().toString();
	    System.out.println("remove:name="+name+",value="+value+"\r\n");
    }

	/**
     * @see HttpSessionAttributeListener#attributeReplaced(HttpSessionBindingEvent)
     */
    public void attributeReplaced(HttpSessionBindingEvent event)  { 
        String name =event.getName();
	    String value =event.getValue().toString();
	    System.out.println("repalce:name="+name+",value="+value+"\r\n");
    }
	
}
